﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>悬疑竞猜管理系统V1.0.0-登录</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
<meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT" />
<link href="../admin/css/css.css" rel="stylesheet" type="text/css" />

<style type="text/css">
body {
	width: 100%;
	height: 100%;
	margin: 0;
	overflow: hidden;
}
</style>
<script src="../admin/js/boot.js" type="text/javascript"></script>

</head>
<body>
	<div id="loginWindow" class="mini-window" title="用户登录"
		style="width: 350px; height: 165px;" showModal="true"
		showCloseButton="false">

		<div id="loginForm" style="padding: 15px; padding-top: 10px;">
			<table>
				<tr>
					<td style="width: 60px;"><label for="username$text">帐号：</label></td>
					<td><input id="username" name="username"
						onvalidation="onUserNameValidation" class="mini-textbox"
						required="true" style="width: 150px;" /></td>
				</tr>
				<tr>
					<td style="width: 60px;"><label for="pwd$text">密码：</label></td>
					<td><input id="pwd" name="pwd" onvalidation="onPwdValidation"
						class="mini-password" requiredErrorText="密码不能为空" required="true"
						style="width: 150px;" onenter="onLoginClick" /></td>
				</tr>
				<tr>
					<td></td>
					<td style="padding-top: 5px;"><a onclick="onLoginClick"
						class="mini-button" style="width: 60px;">登录</a> <a
						onclick="onResetClick" class="mini-button" style="width: 60px;">重置</a>
					</td>
				</tr>
			</table>
		</div>

	</div>

	<script type="text/javascript">
		mini.parse();

		var loginWindow = mini.get("loginWindow");
		loginWindow.show();

		function onLoginClick(e) {
			var form = new mini.Form("#loginWindow");

			form.validate();
			if (form.isValid() == false)
				return;

			$.ajax({
				url : "/suspense-app/coreAccount/login/"
						+ form.getData().username + "/" + form.getData().pwd,
				type : 'post',
				dataType : 'json',
				success : function(text) {
					if (text.success) {
						setCookie("login", "admin");
						loginWindow.hide();
						mini.loading("登录成功，马上进入系统...", "登录成功");
						setTimeout(function() {
							window.location = "home.jsp";
						}, 1500);
					} else {
						mini.alert("请核对账户信息", "提示消息");
					}
				},
				error : function() {
					mini.alert("登录失败", "提示消息");
				}
			});
		}

		function onResetClick(e) {
			var form = new mini.Form("#loginWindow");
			form.clear();
		}

		function onUserNameValidation(e) {
			if (e.isValid) {
				if (e.value.length < 5) {
					e.errorText = "账号不能少于5个字符";
					e.isValid = false;
				}
			}
		}
		function onPwdValidation(e) {
			if (e.isValid) {
				if (e.value.length < 5) {
					e.errorText = "密码不能少于5个字符";
					e.isValid = false;
				}
			}
		}

		//保存30分钟
		function setCookie(name, value) {
			var exp = new Date();
			exp.setTime(exp.getTime() + 30 * 60 * 1000);
			document.cookie = name + "=" + value + "; expires="
					+ exp.toGMTString() + "; path=/";
		}
	</script>
</body>
</html>